package com.ruyuan.eshop.order.service.impl;

import com.ruyuan.eshop.order.dao.AfterSaleLogDAO;
import com.ruyuan.eshop.order.domain.entity.AfterSaleInfoDO;
import com.ruyuan.eshop.order.domain.entity.AfterSaleLogDO;
import com.ruyuan.eshop.order.enums.AfterSaleStatusChangeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author lxg
 * @Description:
 * @date 2022/4/923:31
 */
@Component
public class AfterSaleOperateLogFactory {
    @Autowired
    private AfterSaleLogDAO afterSaleLogDAO;

    public AfterSaleLogDO get(AfterSaleInfoDO afterSaleInfoDO, AfterSaleStatusChangeEnum afterSaleStatusChangeEnum){
        String remark=afterSaleStatusChangeEnum.getOperateRemark();
        int preStatus=afterSaleStatusChangeEnum.getPreStatus().getCode();
        int currentStatus=afterSaleStatusChangeEnum.getCurrentStatus().getCode();
        return create(afterSaleInfoDO, preStatus, currentStatus
        , remark);

    }

    private AfterSaleLogDO create(AfterSaleInfoDO afterSaleInfoDO,int preStatus,int currentStatus,String operateRemark){
        AfterSaleLogDO log =new AfterSaleLogDO();
        log.setAfterSaleId(String.valueOf(afterSaleInfoDO.getAfterSaleId()));
        log.setCurrentStatus(currentStatus);
        log.setPreStatus(preStatus);
        log.setRemark(operateRemark);
        return log;
    }
}
